/*
 *
 *
 * $Id: ReportEvent.java 657 2007-06-29 07:07:01Z jacek.kolezynski $
 */
package logmatcher.report;

/**
*  Event sent by a test component after test finishes. Object holds test result and additional text message.
 */
public class ReportEvent {
    //~ Instance fields ------------------------------------------------------------------------------------------------

    /** Holds test result indicator */
    private Type type;

    /** Additional string message, for instance about failure reason. */
    private String message;
    
    /** Additional object, for sending any additional information. */
    private Object info;

    //~ Constructors ---------------------------------------------------------------------------------------------------

/**
     *  Creates a new ReportEvent object. 
     *  Test result is @link{FAILED} and message is an empty string. 
     */
    public ReportEvent() {
        this(Type.FAILED, "");
    }
    
    /**
     *  Creates a new ReportEvent object. 
     *  Additional message is an empty string. 
     */

    public ReportEvent(Type result){
    	this(result, "");
    }

/**
     *  Creates a new ReportEvent object.
    *
     *  @param result result of test execution
     *  @param message additional message
    */
    public ReportEvent(Type type, String message) {
        this.type = type;
        this.message = message;
    }
    
    /**
     *  Creates a new ReportEvent object.
    *
     *  @param result result of test execution
     *  @param message additional message
    */
    public ReportEvent(Type type, String message, Object info) {
        this.type = type;
        this.message = message;
        this.info = info;
    }

    //~ Methods --------------------------------------------------------------------------------------------------------

    /**
    *  Returns additional message provided by the test.
    *
    *  @return additional message about generation of this event
    */
    public String getMessage() {
        return message;
    }


    /**
    *  Returns result of execution of test that generated this event.
    *
    *  @return test execution result
    */
    public Type getType() {
        return type;
    }


    /**
    *  Sets the message describing this event
    *
    *  @param message additional message
    */
    public void setMessage(String message) {
        this.message = message;
    }


    /**
    *  Sets result of execution.
    *
    *  @param testResult test execution result
    */
    public void setType(Type type) {
        this.type = type;
    }

    //~ Enumeration initializers ---------------------------------------------------------------------------------------

/** Indicates result of test execution */
    public enum Type {//~ Enumeration constant initializers --------------------------------------------------------------------------

        PASSED,FAILED,TEST_ENDED,TEST_STARTED;
    }

public Object getInfo() {
	return info;
}

public void setInfo(Object info) {
	this.info = info;
}
}
